// pages/applyPresentation/applyPresentation.js
const api = require('../../utils/http.js');
var app=getApp();
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		select: 0,
		exchange: [{
			"id":1,
			"icon":"../images/present_way_03.png",
			"exchangeTile": '提现到支付宝',
			"selectStatus": true,
     
    }, {
        "id": 3,
        "icon": "../images/present_way_02.png",
        "exchangeTile": '提现到银行卡',
        "selectStatus": false,

      }, {
			"id":2,
			"icon":"../images/present_way_01.png",
			"exchangeTile": '提现到微信钱包',
			"selectStatus": false,
      
		}]
	},
	exchange(e) {
		let id = e.currentTarget.id;
    console.log(id)
		let up = "exchange[" + id + "].selectStatus";
		this.setData({
			select: id,
			[up]: true
		})
	},
	conformExchange() {
		// api.fetchApi('activity/activity', {
		// 	typeId: this.data.select,
		// }).then(res => {
		// 	if (res.data.code == 2000) {
		// 		wx.showToast({
		// 			title: '成功',
		// 			icon: 'success',
		// 			duration: 2000
		// 		})
		// 	} else {
		// 		wx.showToast({
		// 			title: '失败',
		// 			icon: 'none',
		// 			duration: 2000
		// 		})
		// 	}
		// })
    if (this.data.balance==0){
      wx.showToast({
        title: '余额不足',
        icon:'none'
      })
      return
    }
    	wx.navigateTo({
        url: '/pages/withdrawal/withdrawal?balance=' + this.data.balance + '&pay_type=' + this.data.exchange[this.data.select].id
		})
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
    this.setData({
      balance: options.balance,
      cj: app.globalData.cj || ''
    })
    if(this.data.cj=='qq'){
      var exchange=[{
        "id": 1,
        "icon": "../images/present_way_03.png",
        "exchangeTile": '提现到支付宝',
        "selectStatus": true,

      }, {
        "id": 3,
        "icon": "../images/present_way_02.png",
        "exchangeTile": '提现到银行卡',
        "selectStatus": false,

        },
        //  {
        //   "id": 4,
        //   "icon": "../images/qq_pay.png",
        //   "exchangeTile": '提现到QQ钱包',
        //   "selectStatus": false,

        // }
      ]
      this.setData({
        exchange
      })
     
    }
	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function() {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {

	}
})
